import React from 'react'
import { NavContent, Link } from '../../ui-components'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as reviewAction from '../../actions/review.action' 
//评价活动状态
global.META_TEMPLATE_STATE = {
  '1':'草稿',
  '2':'进行中',
  '3':'已完成',
  '4':'已取消'
}
//受邀评价者的状态
global.META_REVIEWER_STATE = {
  '1':'已完成',
  '2':'撰写中',
  '3':'未评价',
}

const NAV_COMMON = {to: 'peer', label:'反馈给同事'}
const NAV_SELF = {to: 'self', label: '接受反馈'}
const NAV_HR = {to: 'admin', label: '反馈活动管理'}


export default
@connect(({ app, review }) => ({ app, review }), dispatch => ({actions: bindActionCreators({...reviewAction}, dispatch)}))
class Review extends React.Component {
	navItem = ({to, label, active, index}) => (
		<Link active={ ~this.props.location.pathname.indexOf(to) && active} to={'#/review/' + to} color="blue" size="16">{label}</Link>
	)
  componentDidMount() {
    this.props.actions.fetchNavs()
  }
	render() {
    const { roleNameList=[], reporterFullName=null } = this.props.app.profile
    if (!roleNameList.length) return null
    let navData = reporterFullName ? [ NAV_COMMON,  NAV_SELF ] : [ NAV_COMMON ]
    const navs = (~roleNameList.indexOf('HR')) ? [ ...navData,  NAV_HR ] : navData

		return (
			<div>
				{this.props.children}
			</div>
		)
	}
}
